
<div>
    <?php $count = $this->paginator->getTotalItemCount() ?>
    <?php echo $this->translate(array("%s test found", "%s tests found", $count),
        $this->locale()->toNumber($count)) ?>
</div>
<br />
<div class="admin_table_form">
    <table class="admin_table">
    	<thead>
    		<tr>
    			<th> <?php echo $this->translate('image')?> </th>
                <th> <?php echo $this->translate('title')?> </th>
                <th> <?php echo $this->translate('total question')?> </th>
                <th> <?php echo $this->translate('limit score')?> </th>
                <th> <a href="javascript:void(0);" onclick="changeOrder('total_score','desc');"><?php echo $this->translate('score')?></a> </th>
                <th><a href="javascript:void(0);" onclick="changeOrder('total_correct','desc');"><?php echo $this->translate('total correct')?></a> </th>
                <th> <?php echo $this->translate('action')?> </th>
    		</tr>
    	</thead>
    	<tbody>
            <?php foreach($this->paginator as $item):?>
    		<tr>
    			<td><?php echo $this->itemPhoto($item->getExam(),"thumb_icon"); ?></td>
                <td><?php echo $this->string()->truncate($item->getExam()->getTitle(),30) ?></td>
                <td><?php echo $item->getExam()->total_question ?></td>
                <td><?php echo $item->getExam()->max_score ?></td>
                <td><?php echo $item->total_score ?></td>
                <td><?php echo $item->total_correct ?></td>	
                <td>
                    <a href="<?php echo $this->url(array('action'=>'all','exam_id'=>$item->test_id,'format'=>'smoothbox'),'exam_test',true) ?>" ><?php echo $this->translate('All') ?> </a>
                </td>
    		</tr>
            <?php endforeach;?>
    	</tbody>
    </table>
</div>

<div>
    <?php echo $this->paginationControl($this->paginator, null, null, array(
      'pageAsQuery' => true,
      'query' => array_merge(array('format'=>'smoothbox'),$this->formValues)
      //'params' => $this->formValues,
    )); ?>
  </div>
  
<script type="text/javascript">
  var currentOrder = '<?php echo $this->formValues['order'] ?>';
  var currentOrderDirection = '<?php echo $this->formValues['direction'] ?>';
  var changeOrder = function(order, default_direction){
    // Just change direction
    if( order == currentOrder ) {
      $('direction').value = ( currentOrderDirection == 'ASC' ? 'DESC' : 'ASC' );
    } else {
      $('order').value = order;
      $('direction').value = default_direction;
    }
    $('filter_form').submit();
  }
</script>

<div style="display:none">
  <form id="filter_form" method="post">
        <input  type="hidden" value="<?php echo $this->page?>" name="page"/> 
        <input  type="hidden" value="<?php echo $this->formValues['order']?>" name="order" id="order"/> 
        <input  type="hidden" value="<?php echo $this->formValues['direction']?>" name="direction" id="direction"/> 
  </form>
</div>